package com.fitness.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.fitness.model.Address;
import com.fitness.model.AdminUser;
import com.fitness.model.Camp;
import com.fitness.model.Class;
import com.fitness.model.Order;
import com.fitness.model.PrivateTeacher;
import com.fitness.service.ManagementService;

@Controller
public class ManagementController {

	@Autowired
	ManagementService managementService;
	
	/**
	 * 管理员登陆
	 */
	@ResponseBody 
	@RequestMapping(value="api/admin/login",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String login(AdminUser aUser){
		String str = managementService.login(aUser);
		return str;
	}
	/**
	 * 后台用户的增
	 */
	@ResponseBody 
	@RequestMapping(value="api/admin/add",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String adminAdd(AdminUser aUser){
		String str = managementService.adminAdd(aUser);
		return str;
	}
	
	
	/**
	 * 后台用户的删
	 */
	@ResponseBody 
	@RequestMapping(value="api/admin/delete",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String adminDelete(AdminUser aUser){
		String str = managementService.adminDelete(aUser);
		return str;
	}
	
	
	/**
	 * 后台用户的查
	 */
	@ResponseBody 
	@RequestMapping(value="api/admin/search",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String adminSelect(AdminUser aUser){
		String str = managementService.adminSelect(aUser);
		return str;
	}
	
	
	/**
	 * 添加地区
	 */
	@ResponseBody 
	@RequestMapping(value="api/add/area",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String addArea(Address address){
		String str = managementService.addArea(address);
		return str;
	}
	
	/**
	 * 地址表添加数据
	 * @throws IOException 
	 */
	@ResponseBody 
	@RequestMapping(value="api/add/address",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String addAddress(Address address,HttpServletRequest request) {
		String str = managementService.addAddress(address,request);
		return str;
	}
	
	/**
	 * 课程表添加数据
	 */
	@ResponseBody 
	@RequestMapping(value="api/add/class",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String addClass(Class c,HttpServletRequest request) {
		String str = managementService.addClass(c,request);
		return str;
	}
	
	/**
	 * 修改课程表数据
	 */
	@ResponseBody 
	@RequestMapping(value="api/update/class",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String updateClass(Class c) {
		String str = managementService.updateClass(c);
		return str;
	}
	
	/**
	 * 修改课程表数据
	 */
	@ResponseBody 
	@RequestMapping(value="api/update/private",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String updatePrivate(PrivateTeacher p) {
		String str = managementService.updatePrivate(p);
		return str;
	}
	/**
	 * 训练营添加数据
	 */
	@ResponseBody 
	@RequestMapping(value="api/add/camp",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String addCamp(Camp c,HttpServletRequest request) {
		String str = managementService.addCamp(c,request);
		return str;
	}
	
	/**
	 * 训练营表修改数据
	 */
	@ResponseBody 
	@RequestMapping(value="api/update/camp",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String updateCamp(Camp c) {
		String str = managementService.updateCamp(c);
		return str;
	}
	/**
	 * 订单的查询  
	 */
	@ResponseBody 
	@RequestMapping(value="api/order/list",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String orderList(Order order){
		String str = managementService.orderList(order);
		return str;
	}

	/**
	 * 订单的删除 
	 */
	@ResponseBody 
	@RequestMapping(value="api/order/delete",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String orderDelete(Order order){
		String str = managementService.orderDelete(order);
		return str;
	}
	
	
	/**
	 * 地区的删除接口
	 */
	@ResponseBody 
	@RequestMapping(value="api/area/delete",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String areaDelete(Address address){
		String str = managementService.areaDelete(address);
		return str;
	}
	
	/**
	 * 健身房的删除接口
	 */
	@ResponseBody 
	@RequestMapping(value="api/fitness/delete",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String fitnessDelete(Address address){
		String str = managementService.fitnessDelete(address);
		return str;
	}
	
	/**
	 * 课程的删除接口
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/delete",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String classDelete(Class c){
		String str = managementService.classDelete(c);
		return str;
	}
	
	
	/**
	 * 私人教练详情
	 */
	@ResponseBody 
	@RequestMapping(value="api/private/search",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String privateDetail(PrivateTeacher p){
		String str = managementService.privateDetail(p);
		return str;
	}
	
	/**
	 * 私人教练表 删除
	 */
	@ResponseBody 
	@RequestMapping(value="api/private/delete",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String privateDelete(PrivateTeacher p){
		String str = managementService.privateDelete(p);
		return str;
	}
	/**
	 * 私人教练表　添加数据
	 */
	@ResponseBody 
	@RequestMapping(value="api/private/add",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String privateAdd(PrivateTeacher p){
		String str = managementService.privateAdd(p);
		return str;
	}
	/**
	 * 单个训练营详情
	 */
	@ResponseBody 
	@RequestMapping(value="api/camp/search",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String campDetail(Camp camp){
		String str = managementService.campDetail(camp);
		return str;
	}
	
	/**
	 * 训练营删除
	 */
	@ResponseBody 
	@RequestMapping(value="api/camp/delete",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String campDelete(Camp camp){
		String str = managementService.campDelete(camp);
		return str;
	}
	
	/**
	 * 根据   课程类型查询  订单数量统计  人数统计  日期查询  地点查询  课程名查询   电话查询     订单总金额统计
	 */
	@ResponseBody 
	@RequestMapping(value="api/order/alldetail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String orderAllDetail(Order order,HttpServletResponse response){
		String str = managementService.orderAllDetail(order, response);
		return str;
	}
	/**
	 * 图片上传
	 */
	@ResponseBody 
	@RequestMapping(value="api/picture/uploading",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String pictureUploading(@Param("file")MultipartFile file,@Param("address")String address,HttpServletRequest res) throws IOException{
		String str = managementService.pictureUploading(file,address,res);
		return str;
	}
	
	/**
	 * 私教表详情
	 */
	@ResponseBody 
	@RequestMapping(value="api/private/orderDetail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String privateOrderDetail(Order order){
		String str = managementService.privateOrderDetail(order);
		return str;
	}
	
	/**
	 * 教练列表
	 */
	@ResponseBody 
	@RequestMapping(value="api/coach/list",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String coachList(Class  c){
		String str = managementService.coachList(c);
		return str;
	}
	
	/**
	 * 教练id查询详情 
	 */
	@ResponseBody 
	@RequestMapping(value="api/coach/detail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String coachDetail(Class  c){
		String str = managementService.coachDetail(c);
		return str;
	}
	
	/**
	 * 添加教练
	 */
	@ResponseBody 
	@RequestMapping(value="api/coach/add",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String coachAdd(Class  c){
		String str = managementService.coachAdd(c);
		return str;
	}
	
	/**
	 * 教练删除
	 */
	@ResponseBody 
	@RequestMapping(value="api/coach/delete",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String coachDelete(Class  c){
		String str = managementService.coachDelete(c);
		return str;
	}
	
	/**
	 * 修改
	 */
	@ResponseBody 
	@RequestMapping(value="api/coach/update",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String coachupdate(Class  c){
		String str = managementService.coachupdate(c);
		return str;
	}
}
